package pers.cyril.jdb.server;

import com.beust.jcommander.JCommander;
import lombok.extern.slf4j.Slf4j;
import pers.cyril.jdb.common.util.PropertiesParseUtils;
import pers.cyril.jdb.server.command.ConfigCommand;
import pers.cyril.jdb.server.config.ServerConfig;
import pers.cyril.jdb.server.netty.NettyServer;


/**
 * 文件描述
 *
 * @author yichao wang
 */
@Slf4j
public class JDBServer {

    public static void main(String[] args) throws Exception {
        ConfigCommand configCommand = new ConfigCommand();
        JCommander jc = JCommander.newBuilder()
                .programName("jdb")
                .addObject(configCommand).build();
        jc.parse(args);

        PropertiesParseUtils.bindProperties2Object(configCommand.getConfig(), ServerConfig.INSTANCE);

        NettyServer nettyServer = new NettyServer(ServerConfig.INSTANCE.getServerHost(), ServerConfig.INSTANCE.getServerPort());
        nettyServer.start();
    }
}
